import java.util.Scanner;

/**
 * This program finds two neighbouring numbers
 * in an array entered by a user
 * with the smallest distance to each other
 *
 * @author Sergii Koziumynskyi
 * @version 0.03 2014-01-10
 */

public class NeighbouringNumbers {
    public static void main(String[] args) {

        String dirtyInput = getStringFromUser();

        // try to convert the input to expected format
        String[] dirtyInputConverted = dirtyInput.split(" ");
        int[] checkedInput = new int[dirtyInputConverted.length];
        boolean invalidInput = false;
        for (int i = 0; i < dirtyInputConverted.length; i++) {
            try {
                checkedInput[i] = Integer.parseInt(dirtyInputConverted[i]);
            } catch (NumberFormatException nfe) {
                System.out.println("Entered '" + dirtyInputConverted[i] + "' is not an integer value.");
                invalidInput = true;
            }
        }

        // stop execution if input is invalid
        if (invalidInput) {
            System.out.println("Invalid Input. Execution is terminated.");
        } else if (checkedInput.length < 2) {
            System.out.println("Specify more that one number. Execution is terminated.");

        // OR continue execution and perform required calculations if input is valid
        } else {
            int index = getIndexOfFirstNumberWithSmallestDistanceToSecondInArray(checkedInput);
            System.out.println(index);
        }
    }

    /**
     * Method request user for input and return the entered string
     *
     * @return the entered string
     */
    private static String getStringFromUser() {
        Scanner in = new Scanner(System.in);
        System.out.println("Specify several numbers space separated. e.g '4 5 8 3 9')");
        String dirtyInput = in.nextLine().trim();
        in.close();
        return dirtyInput;
    }

    /**
     * Method gets an array of integers,
     * finds two neighbouring numbers in an array with the smallest distance to each other
     * and returns the index of the first number
     *
     * @param checkedInput an array of integers
     * @return an integer value with the index of the first number
     */
    private static int getIndexOfFirstNumberWithSmallestDistanceToSecondInArray(int[] checkedInput) {
        long minDifference = Long.MAX_VALUE;
        int index = -1; // will contain index of a value with min difference
        long tmp1, tmp2; // used to store intermediate calculations

        for (int i = 0; i < checkedInput.length - 1; i++) {

            // find difference between current value and next value
            tmp1 = checkedInput[i] - checkedInput[++i];
//                a question: why tmp1 == 1 instead of expected -4 294 967 295
//                in case of boundary values -2 147 483 648 (checkedInput[i]) - 2 147 483 647 (checkedInput[++i])

            // convert the found difference to positive value in case of necessity
            if (tmp1 < 0) {
                tmp2 = tmp1 * -1;
            } else {
                tmp2 = tmp1;
            }

            // update index if new value is smallest
            if (tmp2 < minDifference) {
                minDifference = tmp2;
                index = --i;
            } else {
                --i;
            }
        }
        return index;
    }
}